using Microsoft.EntityFrameworkCore;
using Abp.IdentityServer4;
using Abp.Zero.EntityFrameworkCore;
using L._52ABP.Common.Consts;
using JYJ.AiYard.Authorization.Roles;
using JYJ.AiYard.DataFileObjects;
using JYJ.AiYard.MultiTenancy;
using JYJ.AiYard.PhoneBooks.Books;
using JYJ.AiYard.PhoneBooks.Persons;
using JYJ.AiYard.UserManagerment.Users;
using JYJ.AiYard.Editions;
using JYJ.AiYard.MultiTenancy.Payments;
using JYJ.AiYard.EntityMapper.SubscriptionPayments;
using JYJ.AiYard.WechatManagement.WechatAppConfigs;
using JYJ.AiYard.EntityMapper.UserManagerment.Users;
using JYJ.AiYard.EntityMapper.DataFileObjects;
using JYJ.AiYard.EntityMapper.MultiTenancy;
using JYJ.AiYard.EntityMapper.WechatManagement.WechatAppConfigs;
using JYJ.AiYard.EntityMapper.Books;
using JYJ.AiYard.EntityMapper.TbAlipayParamss;
using JYJ.AiYard.EntityMapper.TbVipParamss;
using JYJ.AiYard.EntityMapper.TbCCBPayParamss;
using JYJ.AiYard.EntityMapper.TbRoadPayParamss;
using JYJ.AiYard.EntityMapper.TbCIBPayParamss;
using JYJ.AiYard.EntityMapper.TbFFPayParamss;
using JYJ.AiYard.EntityMapper.TbYIDEINVParamss;
using JYJ.AiYard.EntityMapper.TbJLPayParamss;
using JYJ.AiYard.EntityMapper.TbFuiouPayParamss;
using JYJ.AiYard.EntityMapper.TbStationStatuss;
using JYJ.AiYard.EntityMapper.TbClientRegisters;
using JYJ.AiYard.EntityMapper.TbDeparts;
using JYJ.AiYard.EntityMapper.TbDiscountBills;
using JYJ.AiYard.EntityMapper.TbMicroPayParamss;
using JYJ.AiYard.EntityMapper.TbObjectss;
using JYJ.AiYard.EntityMapper.TbSales;
using JYJ.AiYard.EntityMapper.TbStations;
using JYJ.AiYard.EntityMapper.TbUsers;
using JYJ.AiYard.EntityMapper.TbYardBlackLists;
using JYJ.AiYard.EntityMapper.TbYardLovingLists;
using JYJ.AiYard.EntityMapper.TbYardIssuedCards;
using JYJ.AiYard.EntityMapper.TbYardLocalFrees;
using JYJ.AiYard.EntityMapper.TbYardMonthCardOnlines;
using JYJ.AiYard.EntityMapper.TbYardPayNormals;
using JYJ.AiYard.EntityMapper.TbYardPayDayNights;
using JYJ.AiYard.EntityMapper.TbYardPayDayNightNFs;
using JYJ.AiYard.EntityMapper.TbYardPayMonthCards;
using JYJ.AiYard.EntityMapper.TbYardStations;
using JYJ.AiYard.EntityMapper.TbYardUserParkings;
using JYJ.AiYard.EntityMapper.Tb_YardDevices;
using JYJ.AiYard.StationManagement.TbAlipayParams;
using JYJ.AiYard.StationManagement.TbVipParams;
using JYJ.AiYard.StationManagement.TbCCBPayParams;
using JYJ.AiYard.StationManagement.TbCIBPayParams;
using JYJ.AiYard.StationManagement.TbFFPayParams;
using JYJ.AiYard.StationManagement.TbYIDEINVParams;
using JYJ.AiYard.StationManagement.TbJLPayParams;
using JYJ.AiYard.StationManagement.TbFuiouPayParams;
using JYJ.AiYard.StationManagement.TbRoadPayParams;
using JYJ.AiYard.StationManagement.TbClientRegisters;
using JYJ.AiYard.StationManagement.TbDeparts;
using JYJ.AiYard.StationManagement.TbDiscountBills;
using JYJ.AiYard.StationManagement.TbMicroPayParams;
using JYJ.AiYard.StationManagement.TbObjects;
using JYJ.AiYard.StationManagement.TbSales;
using JYJ.AiYard.StationManagement.TbStations;
using JYJ.AiYard.StationManagement.TbUser;
using JYJ.AiYard.StationManagement.TbYardBlackLists;
using JYJ.AiYard.StationManagement.TbYardLovingLists;
using JYJ.AiYard.StationManagement.TbYardDevices;
using JYJ.AiYard.StationManagement.TbYardIssuedCards;
using JYJ.AiYard.StationManagement.TbYardLocalFrees;
using JYJ.AiYard.StationManagement.TbYardMonthCardOnlines;
using JYJ.AiYard.StationManagement.TbYardPayNormals;
using JYJ.AiYard.StationManagement.TbYardPayDayNights;
using JYJ.AiYard.StationManagement.TbYardPayDayNightNFs;
using JYJ.AiYard.StationManagement.TbYardPayMonthCards;
using JYJ.AiYard.StationManagement.TbYardStations;
using JYJ.AiYard.StationManagement.TbYardUserParkings;
using JYJ.AiYard.StationManagement.TbStationParams;
using JYJ.AiYard.StationManagement.TbYardParamsSets;
using JYJ.AiYard.EntityMapper.TbYardParamsSets;
using Abp.Configuration;
using JYJ.AiYard.StationManagement.TbStationStatus;
using JYJ.AiYard.EntityMapper.TbDigitalPaychks;
using JYJ.AiYard.StationManagement.TbDigitalPaychk;
using JYJ.AiYard.StationManagement.TbXiaoJuParams;
using JYJ.AiYard.EntityMapper.TbXiaoJuParamss;
using JYJ.AiYard.StationManagement.TbPPPayParams;
using JYJ.AiYard.EntityMapper.TbPPPayParamss;

using JYJ.AiYard.EntityMapper.TvDigitalPays;
using JYJ.AiYard.StationManagement.TvDigitalPay;
using JYJ.AiYard.StationManagement.TbSUZUploads;
using JYJ.AiYard.EntityMapper.TbSUZUploads;

namespace JYJ.AiYard.EntityFrameworkCore
{
    public class AiYardDbContext : AbpZeroDbContext<Tenant, Role, User, AiYardDbContext>, IAbpPersistedGrantDbContext
    {
        /* Define a DbSet for each entity of the application */

        #region 测试

        public virtual DbSet<Person> People { get; set; }

        public virtual DbSet<Book> Books { get; set; }

        #endregion


        #region 二进制数据

        public virtual DbSet<DataFileObject> DataFileObjects { get; set; }

        #endregion


        #region 订阅

        public virtual DbSet<SubscribableEdition> SubscribableEditions { get; set; }

        public virtual DbSet<SubscriptionPayment> SubscriptionPayments { get; set; }

        #endregion


        #region IdentityServer4

        public virtual DbSet<PersistedGrantEntity> PersistedGrants { get; set; }

        #endregion


        #region 微信

        public virtual DbSet<WechatAppConfig> WechatAppConfigs { get; set; }

        #endregion


        #region AiYard内容
        public DbSet<TbStation> TbStations { get; set; }

        public DbSet<Tb_YardDevice> Tb_YardDevices { get; set; }

        public DbSet<TbUser> TbUsers { get; set; }

        public DbSet<TbDepart> TbDeparts { get; set; }

        public DbSet<TbClientRegister> TbClientRegisters { get; set; }

        public DbSet<TbYardPayNormal> TbYardPayNormals { get; set; }

        public DbSet<TbYardPayDayNight> TbYardPayDayNight { get; set; }
        public DbSet<TbYardPayDayNightNF> TbYardPayDayNightNF { get; set; }

        public DbSet<TbYardPayZMonth> TbYardPayMonthCard { get; set; }

        public DbSet<TbYardLocalFree> TbYardLocalFrees { get; set; }
        public DbSet<TbYardMonthCardOnline> TbYardMonthCardOnlines { get; set; }

        public DbSet<TbYardUserParking> TbYardUserParkings { get; set; }

        public DbSet<TbYardStation> TbYardStations { get; set; }

        public DbSet<TbObjects> TbObjectss { get; set; }

        public DbSet<TbMicroPayParams> TbMicroPayParamss { get; set; }

        public DbSet<TbCCBPayParams> TbCCBPayParamss { get; set; }

        public DbSet<TbRoadPayParams> TbRoadPayParamss { get; set; }

        public DbSet<TbCIBPayParams> TbCIBPayParamss { get; set; }

        public DbSet<TbFFPayParams> TbFFPayParamss { get; set; }

        public DbSet<TbYIDEINVParams> TbYIDEINVParamss { get; set; }
        public DbSet<TbJLPayParams> TbJLPayParamss { get; set; }
        public DbSet<TbFuiouPayParams> TbFuiouPayParamss { get; set; }

        public DbSet<TbXiaoJuParams> TbXiaoJuParamss { get; set; }

        public DbSet<TbPPPayParams> TbPPPayParamss { get; set; }

        public DbSet<TbStationStatus> TbStationStatuss { get; set; }
        public DbSet<TbDigitalPaychk> TbDigitalPaychks { get; set; }
        public DbSet<TvDigitalPay> TvDigitalPays { get; set; }
        public DbSet<TbAlipayParams> TbAlipayParamss { get; set; }
        public DbSet<TbVipParams> TbVipParamss { get; set; }

        public DbSet<TbSale> TbSales { get; set; }

        public DbSet<TbYardBlackList> TbYardBlackLists { get; set; }

        public DbSet<TbYardLovingList> TbYardLovingLists { get; set; }

        public DbSet<TbYardIssuedCard> TbYardIssuedCards { get; set; }

        public DbSet<TbDiscountBill> TbDiscountBills { get; set; }

        public DbSet<TbYardParamsSet> TbYardParamsSets { get; set; }

        public DbSet<TbSUZUpload> TbSUZUploads { get; set; }
        #endregion



        public AiYardDbContext(DbContextOptions<AiYardDbContext> options)
            : base(options)
        {

        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //修改ABP的默认表信息
            modelBuilder.ChangeAbpTablePrefix<Tenant, Role, User>(string.Empty, AbpProEFCoreConsts.SchemaNames.ABP);
            base.OnModelCreating(modelBuilder);


            // ============  其它对表信息的修改 ============= 

            modelBuilder.ApplyConfiguration(new UserCfg());
            modelBuilder.ApplyConfiguration(new SubscriptionPaymentCfg());
            modelBuilder.ApplyConfiguration(new DataFileObjectCfg());
            modelBuilder.ApplyConfiguration(new TenantCfg());

            // ==================== identityServer4 ================================
            modelBuilder.ConfigurePersistedGrantEntity(string.Empty, AbpProEFCoreConsts.SchemaNames.ABP);

            // ==================== Wechat ================================
            modelBuilder.ApplyConfiguration(new WechatAppConfigCfg());
            // ==================== DemoBook ================================
            //   modelBuilder.ApplyConfiguration(new DemoBookCfg());
            modelBuilder.ApplyConfiguration(new BookCfg());

            modelBuilder.ApplyConfiguration(new TbStationCfg());

            //=======================Yard数据库数据表对应表==========================
            modelBuilder.ApplyConfiguration(new Tb_YardDeviceCfg());
            modelBuilder.ApplyConfiguration(new TbUserCfg());
            modelBuilder.ApplyConfiguration(new TbDepartCfg());
            modelBuilder.ApplyConfiguration(new TbClientRegisterCfg());

            modelBuilder.ApplyConfiguration(new TbYardPayNormalCfg());
            modelBuilder.ApplyConfiguration(new TbYardPayDayNightCfg());
            modelBuilder.ApplyConfiguration(new TbYardPayDayNightNFCfg());
            modelBuilder.ApplyConfiguration(new TbYardPayMonthCardCfg());
            modelBuilder.ApplyConfiguration(new TbYardLocalFreeCfg());
            modelBuilder.ApplyConfiguration(new TbYardMonthCardOnlineCfg());
            modelBuilder.ApplyConfiguration(new TbYardUserParkingCfg());
            modelBuilder.ApplyConfiguration(new TbYardStationCfg());
            modelBuilder.ApplyConfiguration(new TbObjectsCfg());
            modelBuilder.ApplyConfiguration(new TbMicroPayParamsCfg());
            modelBuilder.ApplyConfiguration(new TbCCBPayParamsCfg());
            modelBuilder.ApplyConfiguration(new TbCIBPayParamsCfg());
            modelBuilder.ApplyConfiguration(new TbFFPayParamsCfg());
            modelBuilder.ApplyConfiguration(new TbYIDEINVParamsCfg());
            modelBuilder.ApplyConfiguration(new TbJLPayParamsCfg());
            modelBuilder.ApplyConfiguration(new TbFuiouPayParamsCfg());
            modelBuilder.ApplyConfiguration(new TbXiaoJuParamsCfg());
            modelBuilder.ApplyConfiguration(new TbPPPayParamsCfg());
            modelBuilder.ApplyConfiguration(new TbRoadPayParamsCfg());
            modelBuilder.ApplyConfiguration(new TbStationStatusCfg());
            modelBuilder.ApplyConfiguration(new TbDigitalPaychkCfg());
            modelBuilder.ApplyConfiguration(new TvDigitalPayCfg());
            modelBuilder.ApplyConfiguration(new TbAlipayParamsCfg());
            modelBuilder.ApplyConfiguration(new TbVipParamsCfg());

            modelBuilder.ApplyConfiguration(new TbSaleCfg());
            modelBuilder.ApplyConfiguration(new TbYardBlackListCfg());
            modelBuilder.ApplyConfiguration(new TbYardLovingListCfg());
            modelBuilder.ApplyConfiguration(new TbYardIssuedCardCfg());
            modelBuilder.ApplyConfiguration(new TbDiscountBillCfg());

            modelBuilder.ApplyConfiguration(new TbYardParamsSetCfg());
            modelBuilder.ApplyConfiguration(new TbSUZUploadCfg());

        }
    }
}